/*
interface InterfaceLength {
    length: number
}

function getLength(arg: InterfaceLength): number {
    return arg.length
}

console.log(
    getLength("哈哈哈哈"),
    getLength([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
    getLength({length: 100})
)
*/
interface InterfaceLength {
    length: number
}

//    泛型的类型约束
function getLength<Type extends InterfaceLength>(arg: Type): Type {
    return arg
}

console.log(
    getLength("哈哈哈哈"),
    getLength([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
    getLength({length: 100})
)